import request from '@/utils/request.js'
import qs from 'qs'

/** 新增商品 */
export function create(data) {
  return request.post('/shopping/order/create', data)
}

/**
 * 根据ID查询
 * @param {String} id 
 * @returns 
 */
export function byId(id) {
  return request.get(`/shopping/order/${id}`)
}

/**
 * 查询列表
 * @param {Object} data 查询条件
 */
export function list(data) {
  return request.post('/shopping/order/list', data)
}

/** 新增商品 */
export function save(data) {
  return request.post('/shopping/order', data)
}

/** 删除商品 */
export function remove(id) {
  return request.delete(`/shopping/order/${id}`)
}

/** 批量删除商品 */
export function batchRemove(ids) {
  return request.delete('/shopping/order',
    {
      params: {
        ids,
        type: 1
      },
      paramsSerializer: {
        serialize(params) {
          return qs.stringify(params, { indices: false })
        }
      }
    }
  )
}

/** 修改商品 */
export function update(data) {
  return request.put('/shopping/order', data)
}